//
//  MoviesTableViewController.m
//  RGATest
//
//  Created by Pablo Javier Bertola on 2/8/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "MoviesTableViewController.h"

@implementation MoviesTableViewController
@synthesize fetchedResultsController;

-(id)initInManagedObjectContext:(NSManagedObjectContext *)context
{
    if (self = [super initWithStyle:UITableViewStylePlain]) {
        NSFetchRequest *request = [[NSFetchRequest alloc]init];
        request.entity = [NSEntityDescription entityForName:@"Movie" inManagedObjectContext:context];
        request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
        request.predicate = nil;
        request.fetchBatchSize = 20;
        
        NSFetchedResultsController* frc = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:context sectionNameKeyPath:nil cacheName:@"MovieCache"];
        
        [request release];
        self.fetchedResultsController = frc;
        [frc release];
        
        self.title = @"Movies";
    }
    return self;
}

- (void)managedObjectSelected:(NSManagedObject *)managedObject
{
    
}
@end
